From 0735248a601e9c5638587fda0896147b1e7836e6 Mon Sep 17 00:00:00 2001 From: robertlipe Date: Sat, 11 Oct 2014 19:33:32 +0000 Subject: [PATCH] top: prefer std::vector to temp xmalloc. cet: drop unused code. --- gpsbabel/cet_util.cc | 83 -------------------------------------------- gpsbabel/cet_util.h | 1 - gpsbabel/tpo.cc | 14 +++----- 3 files changed, 4 insertions(+), 94 deletions(-) diff --git a/gpsbabel/cet_util.cc b/gpsbabel/cet_util.cc index b1566533f..db70e1275 100644 --- a/gpsbabel/cet_util.cc +++ b/gpsbabel/cet_util.cc @@ -86,55 +86,6 @@ cet_str_any_to_any(const char* src, const cet_cs_vec_t* src_vec, const cet_cs_ve return c1; } -/* %%% cet_valid_char %%% - * - * returnes 1 if convertable otherwise 0 - * - */ - -int -cet_valid_char(const char* src, const cet_cs_vec_t* vec) -{ - int value; - - const cet_cs_vec_t* v = (vec != NULL) ? vec : &cet_cs_vec_ansi_x3_4_1968; - return cet_char_to_ucs4(*src, v, &value); -} - - -#ifdef DEBUG_MEM - -void -cet_check_cs(cet_cs_vec_t* vec) /* test well sorted link & extra tables */ -{ - cet_ucs4_link_t* link; - - if ((link = (cet_ucs4_link_t*)vec->ucs4_link)) { - int i, j; - - for (i = 0, j = 1; j < vec->ucs4_links; i++, j++) { - if (link[i].value >= link[j].value) { - printf(MYNAME ": checked 0x%04x with 0x%04x\n", link[i].value, link[j].value); - fatal(MYNAME ": \"%s\"-link-table unsorted !!!\n", vec->name); - } - - } - } - if ((link = (cet_ucs4_link_t*)vec->ucs4_extra)) { - int i, j; - - for (i = 0, j = 1; j < vec->ucs4_extras; i++, j++) { - if (link[i].value >= link[j].value) { - printf(MYNAME ": check 0x%04x with 0x%04x\n", link[i].value, link[j].value); - fatal(MYNAME ": \"%s\"-extra-table unsorted !!!\n", vec->name); - } - - } - } -} - -#endif - static signed int cet_cs_alias_qsort_cb(const void* a, const void* b) { @@ -537,37 +488,3 @@ cet_convert_strings(const cet_cs_vec_t* source, const cet_cs_vec_t* target, cons printf(", done.\n"); } } - - -/* %%% cet_fprintf / cet_vfprintf %%% - * - * - print any special hard-coded characters from inside a module - */ - -int cet_gbfprintf(gbfile* stream, const cet_cs_vec_t* src_vec, const char* fmt, ...) -{ - int res; - char* cout; - va_list args; - - va_start(args, fmt); - xvasprintf(&cout, fmt, args); - va_end(args); - - if (global_opts.charset != src_vec) { - if (src_vec != &cet_cs_vec_utf8) { - char* ctemp = cet_str_any_to_utf8(cout, src_vec); - xfree(cout); - cout = ctemp; - } - if (global_opts.charset != &cet_cs_vec_utf8) { - char* ctemp = cet_str_utf8_to_any(cout, global_opts.charset); - xfree(cout); - cout = ctemp; - } - } - - res = gbfprintf(stream, "%s", cout); - xfree(cout); - - return res; -} diff --git a/gpsbabel/cet_util.h b/gpsbabel/cet_util.h index 934397e63..c8a58a95f 100644 --- a/gpsbabel/cet_util.h +++ b/gpsbabel/cet_util.h @@ -54,7 +54,6 @@ extern cet_cs_vec_t cet_cs_vec_utf8; /* helpers */ char* cet_str_any_to_any(const char* src, const cet_cs_vec_t* src_vec, const cet_cs_vec_t* dest_vec); -int cet_valid_char(const char* src, const cet_cs_vec_t* vec); int cet_gbfprintf(gbfile* stream, const cet_cs_vec_t* src_vec, const char* fmt, ...); diff --git a/gpsbabel/tpo.cc b/gpsbabel/tpo.cc index 159f19c9c..1e1bdaafd 100644 --- a/gpsbabel/tpo.cc +++ b/gpsbabel/tpo.cc @@ -258,7 +258,6 @@ void tpo_read_2_x(void) char buff[16]; short track_count, waypoint_count; double first_lat, first_lon, lat_scale, lon_scale, amt; - short* lon_delta, *lat_delta; int i, j; route_head* track_temp; Waypoint* waypoint_temp; @@ -312,10 +311,10 @@ void tpo_read_2_x(void) waypoint_count = gbfgetint16(tpo_file_in); /* allocate temporary memory for the waypoint deltas */ - lon_delta = (short*) xmalloc(waypoint_count * sizeof(short)); - lat_delta = (short*) xmalloc(waypoint_count * sizeof(short)); + std::vector lat_delta(waypoint_count); + std::vector lon_delta(waypoint_count); - for (j=0; j